<link rel="stylesheet" href="<?= $this->baseUrl() ?>/css/ui.datepicker.css"/>
<script type="text/javascript" src="<?=$this->baseUrl()?>/js/jquery.cookie.js"></script>
<script type="text/javascript" src="<?= $this->baseUrl() ?>/js/jq.date.js"></script>
<script type="text/javascript">
    $(document).ready(function(){
        receiveData('table');

        $('#date').datepicker({dateFormat: 'yy-mm-dd',
            clickInput:false}); // format: Thurs, Jan 31, 2008, only show when the user clicks the calendar
        $('#find').click(function(){
            receiveData('table');
        });

    });

    function receiveData(href){
        var options;
        if($('#date').val().length==0) options = {statusId : 5};
        else options = {statusId : 5, date : $('#date').val()};
        
        $.post(href, options, function(data){
            document.getElementById('received').innerHTML = data;
            $("a#link").click(function(){
                $.cookie('prevpage', 'received');
            });
            $('#received a.nav').click(function(event){
                event.preventDefault();
                var href = $(this).attr('href');
                receiveData(href);
            });
            $('#received select.nav').removeAttr('onchange');
            $('#received select.nav').change(function(){
                var href = '<?=$this->baseUrl()?>/transaction/table/page/' + $(this).val();
                receiveData(href);
            });
        });
    }

    function cancel(transactionId,code){
        if(confirm('Hapus transaksi ' + code + '?')){
            document.frmDelete.transactionId.value = transactionId;
            document.frmDelete.submit();
        }
    }
</script>
<div id="view-content">
    <div id="search">
        Tanggal penerimaan: <?=$this->formText("date",null,array("id"=>"date","readonly"=>"true"))?>
        <?=$this->formButton("find","Cari",array("id"=>"find"))?>
    </div>
    <div id="received">
        <!-- Table content is loaded using JQuery ajax -->
        <div style ="padding:10px;">Loading...</div>
    </div>
    <div id="hiddenform" style="display:none;">
        <form name="frmDelete" method="POST">
            <?php echo $this->formHidden("transactionId","0"); ?>
            <?php echo $this->formHidden("delete","Hapus"); ?>
        </form>
    </div>
</div>